package cn;

import cn.config.JavaConfig;
import cn.dao.StuDao;
import cn.domain.Clazz;
import cn.domain.Stu;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@Slf4j //log
public class Demo {
  public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx=new AnnotationConfigApplicationContext(JavaConfig.class);
    Stu stu=ctx.getBean(Stu.class);
    log.debug("spring创建的bean {}",stu);
    //多个同类型的bean
//    Stu stu2=ctx.getBean("stu",Stu.class);//默认的名字是方法名
    Stu stu2=ctx.getBean("jee-stu",Stu.class);//自定义名字后，默认名字消失
    log.info("通过名字得到bean {}",stu2);
    Clazz clazz=ctx.getBean(Clazz.class);
    log.info("类间关系 {}",clazz);

    StuDao dao=ctx.getBean(StuDao.class);
    dao.query();
  }
}
